main(i){char c;for(gets(&i);~scanf("%c%d\n",&c,&i);){if(c==67)i=(9/5.)*i+32;else i=(5/9.)*(i-32);printf("%d\n",i);}}
